package com.hue.concurrent.day02;

/*
    使用多线程解决统筹方法
 */
public class Demo01 {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            System.out.println("t1开始洗水壶...");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("t1水壶洗好了，开始烧水");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("t1水烧好了");
        }, "t1");

        Thread t2 = new Thread(() -> {
            System.out.println("t2开始洗茶壶、水杯、拿茶叶");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("t2洗茶壶、水杯、拿茶叶好了，等待水开");
            try {
                t1.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("t2开始泡茶");
        }, "t2");
        t1.start();
        t2.start();
    }
}
